package java51_20;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

public class DateFormaterTest {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		System.out.println("请输入日期");
		String s = sc.next();
		SimpleDateFormat format = new SimpleDateFormat();
		format.setLenient(false);
		String[] pattern = { "yyyy/MM/dd", "yyyyMMdd", "yyyy-MM-dd" };
		for (String sp : pattern) {
			try {
				format.applyPattern(sp);
				Date d = format.parse(s);
				System.out.println(d);
				return;
			} catch (ParseException e) {
				// TODO 自动生成的 catch 块
				// e.printStackTrace();
			}

		}
		System.out.println("输入错误");
	}

}
